//
//  LDSLightCollectionViewCell.m
//  LDSSmartHome
//
//  Created by kai_leedarson on 2017/10/10.
//  Copyright © 2017年 leedarson. All rights reserved.
//

#import "LDSSliderCollectionCell.h"
#import "LDSSliderModel.h"
#import "LDSEventListViewController.h"

@interface LDSSliderCollectionCell ()
@property(nonatomic, strong) LDSEventListViewController *eventListViewController;
@property(nonatomic, strong) UIView *vcView;
@end

@implementation LDSSliderCollectionCell
- (LDSEventListViewController *)eventListViewController {
    if(_eventListViewController == nil) {
        _eventListViewController = [[LDSEventListViewController alloc] init];
    }
    return _eventListViewController;
}

- (UIView *)vcView {
    if(_vcView == nil) {
        _vcView = self.eventListViewController.view;
    }
    return _vcView;
}

- (void)viewSetup {
    _name = [UILabel new];
    _name.text = @"";
    _name.textColor = [UIColor lightGrayColor];
    _name.textAlignment = NSTextAlignmentCenter;
    _name.font = [UIFont systemFontOfSize:12.0f];
    _name.numberOfLines = 0;
    [_name sizeToFit];
    
    _photo = [[UIImageView alloc] init];
    _photo.contentMode = UIViewContentModeScaleAspectFit;
    _iconPhoto = [[UIImageView alloc] init];
    _iconPhoto.contentMode = UIViewContentModeScaleAspectFit;
    
    [self.contentView addSubview:_photo];
    [self.contentView addSubview:_iconPhoto];
    [self.contentView addSubview:_name];
    [self.contentView addSubview:self.vcView];
}

- (void)frameSetup {
    _photo.frame = CGRectMake(0,0,self.bounds.size.width,self.bounds.size.height - 51);
    _name.frame = CGRectMake(5,self.bounds.size.height - 40,self.bounds.size.width - 10,40);
    _iconPhoto.frame = CGRectMake((self.bounds.size.width - 18)/2, self.bounds.size.height - 60, 18, 18);
    self.backgroundColor = [UIColor redColor];
    _vcView.frame = self.frame;
}

- (void)setModel:(LDSSliderModel *)model {
    [super setModel:model];
    if (model) {
        self.name.text = model.name;
        self.photo.image = [UIImage imageNamed:model.imageName];
        self.iconPhoto.image = [UIImage imageNamed:@"devicemanage_icon_cloud_offline"];
    }
}
@end
